/**
* @file Timer.h
* @author Max Ocklind (original by "alex79roma" at http://www.cplusplus.com/forum/beginner/317/)
* @version 2010-01-11
**/


#if !defined(TIMER_H)
#define TIMER_H


/* includes */

#include <time.h>


/* defines */

#define NO_TIME_LIMIT -1


/* classes */

class Timer
{
public:
	/**
	* The default constructor that initiates the member variables.
	*/
	Timer()
	{
		mResetted = true;
		mRunning  = false;
		mBeg	  = 0;
		mEnd	  = 0;
		mLimit	  = NO_TIME_LIMIT;
	} /* Timer() */

	void           start();
	void		   start(unsigned long timeLimit);
	void           stop();
	void           reset();
	bool           isRunning();
	unsigned long  getTime();
	bool           isOver(unsigned long seconds);
	bool           isOverLimit();
	void		   setLimit(unsigned long seconds);
	unsigned long  getLimit();

private:
	bool           mResetted;
	bool           mRunning;
	unsigned long  mBeg;
	unsigned long  mEnd;
	unsigned long  mLimit;
}; /* Timer */


#endif /* TIMER_H */